

#include <iostream>

#include "teststring.h"

#include "cpptoolbox/string.h"

static void testToUpper();
static void testToLower();
static void testSplit();
static void testPad();
static void testTrim();

void teststring(){
    testToUpper();
    testToLower();
    testSplit();
    testPad();
    testTrim();
}


void testToUpper(){
    
    std::cout << "Test cpptoolbox::toUpper()" << std::endl;
    
    std::string lower = "lower case string";
    
    std::cout << "lower = \"" << lower << "\"" << std::endl;
    std::cout << "toUpper() = \"" << cpptoolbox::toUpper(lower) << "\"" << std::endl;
    
}

static void testToLower(){
    std::cout << "Test cpptoolbox::toLower()" << std::endl;
    
    std::string upper = "UPPER CASE STRING";
    
    std::cout << "upper = \"" << upper << "\"" << std::endl;
    std::cout << "toLower() = \"" << cpptoolbox::toLower(upper) << "\"" << std::endl;
}

static void testSplit(){
    std::cout << "Test cpptoolbox::split()" << std::endl;
    
    std::string tosplit = "a-string-to-split";
    
    std::cout << "tosplit = \"" << tosplit << "\"" << std::endl;
    std::vector<std::string> splited = cpptoolbox::split(tosplit, '-');
    for(int i = 0; i < splited.size(); i++){
        std::cout << "splited[" << i << "] = \"" << splited[i] << "\"" << std::endl;
    }
}

static void testPad(){
    std::cout << "Test cpptoolbox::pad()" << std::endl;
    
    std::string topad = "a string to pad";
    
    std::cout << "to pad = \"" << topad << "\"" << std::endl;
    
    std::cout << "pad 20 left = \"" << cpptoolbox::pad(topad, 20, '-', cpptoolbox::align_left) << "\"" << std::endl;
    std::cout << "pad 20 right = \"" << cpptoolbox::pad(topad, 20, '-', cpptoolbox::align_right) << "\"" << std::endl;
    std::cout << "pad 20 center = \"" << cpptoolbox::pad(topad, 20, '-', cpptoolbox::align_center) << "\"" << std::endl;
}

static void testTrim(){
    std::cout << "Test cpptoolbox::trim*()" << std::endl;
    
    std::string totrim = "------//---//a string to trim--//-//--";
    
    std::cout << "to trim = \"" << totrim << "\"" << std::endl;
    
    std::cout << "trim_left = \"" << cpptoolbox::trim_left(totrim, "-/") << "\"" << std::endl;
    std::cout << "trim right = \"" << cpptoolbox::trim_right(totrim, "-/") << "\"" << std::endl;
    std::cout << "trim = \"" << cpptoolbox::trim(totrim, "-/") << "\"" << std::endl;
    //std::cout << "pad 20 center = \"" << cpptoolbox::pad(totrim, 20, '-', cpptoolbox::align_center) << "\"" << std::endl;
}


